﻿/* Write a program that reads a string from the console and prints all different letters in the string along with information how many times each letter is found */
using System;
using System.Collections.Generic;

namespace _21.PrintDifferentLetters
{
    class PrintDifferentLetters
    {
        static void Main()
        {
            string str = "find my different letters bitch";
            //string letters = "abcdefghijklmnophijklmnopqrstuvwxyz";

            List<char[]> l = new List<char[]>();

            List<char> letters = new List<char>();
            List<int> numbers = new List<int>();
            letters.Add(str[0]);
            numbers.Add(1);
            bool check = false;
            for (int i = 1; i < str.Length; i++)
            {
                if (Char.IsLetter(str[i]))
                {
                    for (int j = 0; j < letters.Count; j++)
                    {

                        if (str[i] == letters[j])
                        {
                            numbers[j]++;
                            check = true;
                            break;
                        }
                    }
                    if (!check)
                    {
                        letters.Add(str[i]);
                        numbers.Add(1);
                    }
                    check = false;
                }
                else
                {
                    continue;
                }
            }
            Console.WriteLine("Found occurances: ");
            for (int i = 0; i < letters.Count; i++)
            {
                Console.WriteLine(@"'{0}':{1} times", letters[i], numbers[i]);
            }
        }
    }
}
